<style>
  .sphboard { width: 100%; }
  textarea { width: 100%; }
  .sphboard input { width: 100%; }
</style>
  <script language="JavaScript" type="text/javascript" src="/static/sphene/community/xmlhttp.js"></script>
  <script language="JavaScript" type="text/javascript">
  <!--
   function doPreview() {
     var markup = "";
     if(document.postform.markup) {
       markup = "&markup=" + escape( document.postform.markup.value );
     }
     showResponseInElement( 'previewarea', 'Loading Preview ....', "type=preview" + markup + "&body=" + escape( document.postform.body.value ) );
   }
  //-->
  </script>

<div id="previewarea" style="display:none; visibility:hidden; border: 2px solid gray; overflow:scroll; max-height: 500px; padding: 5px;"></div>
<form method="post" action="." name="postform">
  <input type="hidden" name="category" value="{{ category.id }}" />
  {% if thread %}
    <input type="hidden" name="thread" value="{{ thread.id }}" />
  {% endif %}
  <table class="sphboard form">
    {{ form }}
  </table>
    {% if user.is_authenticated %}
          {% if thread.has_monitor or category.has_monitor %}
            <small>You are already receiving email notifications for this thread or category.</small>
          {% else %}
            <input type="checkbox" name="addmonitor" value="1" id="addmonitor_id" checked="checked" /> <label for="addmonitor_id">Notify me by email on new posts in this thread.</label>
          {% endif %}
          <br/><br/>
    {% endif %}

  {% if not thread and not post %}
  <input type="checkbox" name="createpoll" value="1" onchange="javascript:document.getElementById( 'poll' ).style.display = (this.checked ? 'block' : 'none' )" id="createpoll_id"{% if createpoll %} checked="checked"{% endif %} /> <label for="createpoll_id">Add a poll to this thread</label><br/><br/>

  <div id="poll" style="display: none">
    <table class="sphboard form">
      <tr>
        <th colspan="2">Poll</th>
      </tr>
      {{ pollform }}
    </table>
  </div>
  <script language="JavaScript">
  <!--
    document.getElementById( 'poll' ).style.display = (document.postform.createpoll.checked ? 'block' : 'none');
  //-->
  </script>
  {% endif %}

  <input type="submit" value="Post" /> * <input type="button" value="Preview" onclick="javascript:doPreview()" />

</form>
